Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace flake8 and isort with ruff #6128

Merged
merged 1 commit into from
Sep 22, 2023
Merged

Replace flake8 and isort with ruff #6128

merged 1 commit into from
Sep 22, 2023

Conversation

dafeda
Copy link
Contributor

@dafeda dafeda commented Sep 21, 2023

Flake8 does not support pyproject.toml out-of-the box and ruff is faster.

Pre review checklist

  • Read through the code changes carefully after finishing work
  • Make sure tests pass locally (after every commit!)
  • Prepare changes in small commits for more convenient review (optional)
  • PR title captures the intent of the changes, and is fitting for release notes.
  • Updated documentation
  • Ensured that unit tests are added for all new behavior (See
    Ground Rules),
    and changes to existing code have good test coverage.

Pre merge checklist

  • Added appropriate release note label
  • Commit history is consistent and clean, in line with the contribution guidelines.

@codecov-commenter
Copy link

codecov-commenter commented Sep 21, 2023

Codecov Report

Merging #6128 (5c8e696) into main (8a15332) will decrease coverage by 0.01%.
Report is 1 commits behind head on main.
The diff coverage is 77.35%.

@@            Coverage Diff             @@
##             main    #6128      +/-   ##
==========================================
- Coverage   82.42%   82.41%   -0.01%     
==========================================
  Files         350      350              
  Lines       21457    21423      -34     
  Branches      839      839              
==========================================
- Hits        17685    17656      -29     
+ Misses       3474     3469       -5     
  Partials      298      298              
Files Changed Coverage Δ
src/ert/__main__.py 81.60% <0.00%> (ø)
src/ert/analysis/_es_update.py 88.17% <0.00%> (ø)
src/ert/config/ert_config.py 94.88% <0.00%> (-0.28%) ⬇️
src/ert/config/model_config.py 96.61% <ø> (ø)
src/ert/config/parsing/lark_parser.py 98.68% <ø> (ø)
src/ert/config/parsing/observations_parser.py 97.53% <ø> (ø)
src/ert/data/record/_record.py 43.67% <0.00%> (ø)
.../gui/tools/manage_cases/case_init_configuration.py 96.36% <0.00%> (+1.72%) ⬆️
src/ert/gui/tools/plot/plot_api.py 92.50% <0.00%> (ø)
src/ert/config/analysis_module.py 89.47% <100.00%> (ø)
... and 21 more

... and 4 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@dafeda dafeda self-assigned this Sep 21, 2023
@dafeda dafeda added maintenance Not a bug now but could be one day, repaying technical debt release-notes:skip If there should be no mention of this in release notes labels Sep 21, 2023
@berland
Copy link
Contributor

berland commented Sep 21, 2023

I would like not to mix the shift from isort+flake8 to ruff with the actual fixing of the issues. Can we have a PR that only converts the style tooling (adding more exceptions if needed), and then fixing and removing exceptions in future PRs

@dafeda
Copy link
Contributor Author

dafeda commented Sep 21, 2023

I would like not to mix the shift from isort+flake8 to ruff with the actual fixing of the issues. Can we have a PR that only converts the style tooling (adding more exceptions if needed), and then fixing and removing exceptions in future PRs

Not sure I agree since this makes it clear that the changes were done to please the linter, but I'll see what I can do.

@@ -167,8 +167,8 @@ def valid_num_iterations(user_input: str) -> str:
def attemp_int_conversion(val: str) -> int:
try:
return int(val)
except ValueError:
raise ArgumentTypeError(f"{val} is not a valid integer")
except ValueError as e:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like an automated fix. Is it given that we always want to reraise exceptions and keep all the details (it probably often is). When seen by users, more details can make them blind.

If this is a new requirement imposed by ruff, it would like to have a global exception for it in ruff-configuration, and then we can think about solving it in a future PR.

Copy link
Contributor Author

@dafeda dafeda Sep 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really automated, I just did not see any reason to hide the context and yes, it makes ruff happy.
Also, I'm not really sure what the difference would be between the two in the specific function.
I would guess that they do the same thing.

Copy link
Collaborator

@oyvindeide oyvindeide left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a good improvement!

@@ -266,7 +266,7 @@ def get_documentation_for_jobs(self) -> Dict[str, Any]:
self.hook.installable_jobs(), include_plugin_data=True
).items()
}
for k in job_docs.keys():
for k in job_docs:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know what k is? Not introducing it, I know, but if you know, perhaps rename it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what it is unfortunately.

@@ -35,9 +35,7 @@ def test_using_qt_model_tester(qtmodeltester, full_snapshot):
model.setSourceModel(source_model)

reporting_mode = qt_api.QtTest.QAbstractItemModelTester.FailureReportingMode.Warning
tester = qt_api.QtTest.QAbstractItemModelTester( # noqa, prevent GC
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps relevant to keep the prevent GC part of the comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@@ -56,9 +54,7 @@ def test_changes(full_snapshot):
model.setSourceModel(source_model)

reporting_mode = qt_api.QtTest.QAbstractItemModelTester.FailureReportingMode.Warning
tester = qt_api.QtTest.QAbstractItemModelTester( # noqa, prevent GC
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@dafeda dafeda merged commit fe150c6 into equinor:main Sep 22, 2023
41 checks passed
@dafeda dafeda deleted the ruff branch September 22, 2023 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Not a bug now but could be one day, repaying technical debt release-notes:skip If there should be no mention of this in release notes
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants